# flake8: NOQA

import redis

size = 10000
r = redis.Redis()
count = 0
for i in range(size):
    #添加元素，key为userid，值为user0...user9999
    r.execute_command("bf.add", "userid", "user%d" % i)
    #判断元素是否存在，此处切记 i+1
    res = r.execute_command("bf.exists", "userid", "user%d" % (i + 1))
    if res == 1:
        print(i)
        count += 1
#求误判率，round()中的5表示保留的小数点位数
print("size: {} ,error rate:{}%".format(size, round(count / size * 100, 5)))